# 输入poc  ssvid 编号
# 输出     cve执行结果
from pocsuite3.api import init_pocsuite
from pocsuite3.api import start_pocsuite
from pocsuite3.api import get_results
import sys


class pocc():
    def __init__(self):
        pass

    def run_pocsuite(self, url, poc):
        config = {
        'url': url,
        'poc': poc,
        }
        ststdin = sys.stdin
        conff = open("./scan/pocc/account.txt", "r")
        sys.stdin = conff
        init_pocsuite(config)
        start_pocsuite()
        result = get_results()
        sys.stdin = ststdin
        conff.close()
        return result

    def get_result(self, url, poclist):
        # poc = ['ecshop_rce', 'ftp_burst', 'ssh_burst',
        #     'telnet_burst', 'libssh_auth_bypass', 'drupalgeddon2']
        poc = ['ecshop_rce', 'ssh_burst']
        if poclist:
            print(poc)
            print(poclist)
            pass
        else:
            poc.extend(poclist)
        result = self.run_pocsuite(url,poc)

        for x in range(len(result)):
            if result[x]["status"] == "success":
                for key,values in result[x].items():
                    print(key,":",values)
            else:
                print(result[x]["app_name"],":","failed")
                
        return result

    

   
    
